<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "user_signin_pay".
 *
 * @property int $id
 * @property int $user_id 用户id
 * @property int $signin_id 对应签约记录id
 * @property string $out_trade_no 交易码
 * @property string $price 价格
 * @property int $is_pay 是否支付
 * @property string $create_time 订单创建时间
 * @property int $status 状态
 *
 * @property User $user
 * @property User $user0
 * @property UserSignin $signin
 */
class UserSigninPay extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_signin_pay';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'signin_id'], 'required'],
            [['user_id', 'signin_id', 'is_pay', 'status'], 'integer'],
            [['out_trade_no'], 'string'],
            [['create_time'], 'safe'],
            [['price'], 'string', 'max' => 10],
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
            [['signin_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserSignin::className(), 'targetAttribute' => ['signin_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_id' => '用户id',
            'signin_id' => '对应签约记录id',
            'out_trade_no' => '交易码',
            'price' => '价格',
            'is_pay' => '是否支付,1支付,0未支付',
            'create_time' => '订单创建时间',
            'status' => '状态',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser0()
    {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSignin()
    {
        return $this->hasOne(UserSignin::className(), ['id' => 'signin_id']);
    }
}
